import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import UserView from "@/components/UserView.vue";
import UserLogin from "@/user/UserLogin.vue";
import UserLayout from "@/layout/UserLayout.vue";
import UserRegister from "@/user/UserRegister.vue";
import ACCESS_ENUM from "@/access/accessEnum";
import RoomView from "@/components/RoomView.vue";
import RoomDetail from "@/components/RoomDetail.vue";
import RoomManage from "@/components/RoomManage.vue";
import UserManage from "@/components/userManage.vue";
import BuildingInfoManage from "@/components/BuildingInfoManage.vue";

const routes: Array<RouteRecordRaw> = [
  {
    path:"/myself",
    name:"用户信息",
    component:UserView,
  },
  {
    path:"/roomView",
    name:"出租房间",
    component:RoomView,
    meta: {
      access: ACCESS_ENUM.CUSTOMER,
    },
  },
  {
    path:"/roomManage",
    name:"房间管理",
    component:RoomManage,
    meta: {
      access: ACCESS_ENUM.ADMIN,
    },
  },
  {
    path:"/iUserManage",
    name:"用户管理",
    component:UserManage,
    meta: {
      access: ACCESS_ENUM.SUPERADMIN,
    },
  },
  {
    path:"/buildingInfo",
    name:"水电管理",
    component:BuildingInfoManage,
    meta: {
      access: ACCESS_ENUM.ADMIN,
    },
  },
  {
    path:"/room/detail",
    name:"出租屋细节",
    component:RoomDetail,
    meta:{
      access: ACCESS_ENUM.CUSTOMER,
      hideInMenu: true,
    },
  },
  {
    path:"/user",
    name:"用户",
    component:UserLayout,
    children:[
      {
        path:"/user/login",
        name:"用户登录",
        component:UserLogin,
      },
      {
        path:"/user/register",
        name:"用户注册",
        component:UserRegister,
      }
    ],
    meta:{
      hideInMenu: true,
    }
  },

  {
    path:"/roomDetail/:id",
    name:"房间细节",
    component:RoomDetail,
    meta:{
      hideInMenu: true,
    }
  },
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
